using System;

namespace HexLib.Url
{
	public delegate void DownloadCompleteHandler( byte[] dataDownloaded );

	/// <summary>
	/// Summary description for DownloadThread.
	/// </summary>
	public class DownloadThread
	{
		public event DownloadCompleteHandler CompleteCallback;
		public event DownloadProgressHandler ProgressCallback;

		public string _downloadUrl = "";
		public string DownloadUrl
		{
			get
			{
				return _downloadUrl;
			}
			set
			{
				_downloadUrl = value;
			}
		}

		public void Download()
		{
			if ( CompleteCallback != null && 
				  DownloadUrl != "" )
			{
				WebDownload webDL = new WebDownload();
				byte[] downloadedData = webDL.Download(DownloadUrl, 
																	ProgressCallback );
				CompleteCallback( downloadedData );
			}
		}
	}
}
